$(function() {
	/**顶部搜索**/
	$("#searchBtn").click(function() {
		var searchType = $(this).prev(".header-search-box").find(".analog-select dt").text();
		if (searchType == "课程") {
			window.location.href = "search-course.html";
		} else if (searchType == "讲师") {
			window.location.href = "search-lecturer.html";
		} else if (searchType == "机构") {
			window.location.href = "search-org.html";
		} else if (searchType == "标准") {
			window.location.href = "search-standard.html";
		}
	});
	
	/**模拟下拉选择框**/
	$(".analog-select dt").click(function() {
		$(this).toggleClass("checked").next("dd").slideToggle();
	});
	$(".analog-select dd a").click(function() {
		var asTxt = $(this).text();
		$(this).closest(".analog-select dd").slideUp().prev("dt").text(asTxt).removeClass("checked");
	});
	
	/**关注**/
	$(".concern").click(function() {
		$(this).toggleClass("concerned");
	});
	
	/*切换排序方式*/
	$(".ovd-tabs li").click(function() {
		$(this).addClass("active").siblings("li").removeClass("active");
		var ovdTabsP = $(this).hasClass("price");
		if (ovdTabsP == false) {
			$(".ovd-tabs li.price a").attr("class", "");
		}
		var ovdTabsC = $(this).hasClass("classify");
		if (ovdTabsC == false) {
			$(".ovd-tab-classify").slideUp();
		}
	});
	/*按价格高低排序*/
	$(".ovd-tabs li.price").click(function() {
		var priceState = $(this).find("a").attr("class");
		if (priceState == "descending" || priceState == undefined || priceState == "") {
			$(this).find("a").attr("class", "ascending");
		} else if (priceState == "ascending") {
			$(this).find("a").attr("class", "descending");
		}
	});
	/*按分类显示*/
	$(".ovd-tabs li.classify>a").click(function() {
		$(this).toggleClass("open").next(".ovd-tab-classify").slideToggle();
	});
	$(".ovd-tab-classify>a").click(function() {
		$(this).parent(".ovd-tab-classify").slideUp().prev("a").removeClass("open");
	});
	
	/**三道杠菜单**/
	$(".header-menu dt").click(function() {
		$(this).next("dd").fadeToggle();
	});
	$(".header-menu dd a").click(function() {
		$(this).parent("dd").fadeOut();
	});
	/*分享*/
	$(".three-bars-share").click(function() {
		$(".share-pop").animate({"bottom": 0});
		$("#sharePopMask").show();
	});
	$(".share-medium a, #cancelShare").click(function() {
		$(".share-pop").animate({"bottom": "-50%"});
		$("#sharePopMask").hide();
	});
});
